package com.netbetter.langzheng.plugin.fileManager;

import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.netbetter.langzheng.commons.constants.AppEvents;

/**
 * 文件管理控制器
 * 
 * @author 嘉陵江里捉鱼
 * 
 */
public class FileManagerController extends Controller {

  private FolderNavigationView folderView;
  private ListView listView;

  public FileManagerController() {
    registerEventTypes(AppEvents.Init);
    registerEventTypes(AppEvents.NAVLASTVIEW);
    registerEventTypes(AppEvents.ViewLIST);
    registerEventTypes(AppEvents.NavFolder);
  }

  @Override
  public void handleEvent(AppEvent<?> event) {
    switch (event.type) {
      case AppEvents.Init:
        forwardToView(folderView, event);
        break;
      case AppEvents.NAVLASTVIEW:
        forwardToView(folderView, event);
        forwardToView(listView, event);
        break;
      case AppEvents.ViewLIST:
        forwardToView(listView, event);
        break;
      case AppEvents.NavFolder:
        forwardToView(folderView, event);
        break;
    }
  }

  public void initialize() {
    folderView = new FolderNavigationView(this);
    listView = new ListView(this);
  }

}
